﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using EF_Model;
using Moq;
using System;
using System.Data.Objects;
using System.Linq;

namespace EF_Tests
{
    public interface IMyClass
    {
        string SampleMethod();
    }

    [TestClass]
    public class temp1
    {
        [TestMethod]
        public void TestMethod()
        {
            Mock<IMyClass> myClass = new Mock<IMyClass>();
            string s = myClass.Object.SampleMethod().ToString();
        }

        [TestMethod]
        public void Dummy_Read()
        {
            DatabaseContext dbContext = new DatabaseContext();
            CustomerRepository cr = new CustomerRepository(dbContext);

            Customer c = new Customer();
            c.CustomerID = "118";
            c.ContactName = "xxx-118";
            c.CompanyName = "com-001";

            
            IObjectSet<Customer> oc = dbContext.Customers;
            dbContext.Customers.AddObject(c);

            //AddObject will not a object searchable by LINQ queries unless dbContext.SaveChanges() is called/physically written.

            //dbContext.SaveChanges();
            //var first = dbContext.Customers..FirstOrDefault(c1 => c1.CustomerID == "118");
            var first = oc.FirstOrDefault(c1 => c1.CustomerID == "118");
            Console.Write(first.ContactName);//fails
        }
    }
}
